package com.allwees.bs.module.ums.rest;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.allwees.bs.core.modelbase.vo.R;
import com.allwees.bs.module.ums.entity.CustomerCash;
import com.allwees.bs.module.ums.entity.CustomerCashLog;
import com.allwees.bs.module.ums.req.CustomerCashCrudReq;
import com.allwees.bs.module.ums.req.query.CustomerCashLogQueryReq;
import com.allwees.bs.module.ums.service.CustomerCashService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/backstage/api/ums/customer-account")
public class CustomerAccountApi {

    @Autowired
    private CustomerCashService customerCashService;

    @GetMapping("/cash/log-page")
    public R logPage(Page<CustomerCashLog> page, CustomerCashLogQueryReq req) {
        Page<CustomerCashLog> logPage = customerCashService.logPage(page, req);
        return R.ok(logPage);
    }

    @GetMapping("/cash/{userUuid}")
    public R cashAdd(@PathVariable String userUuid) {
        CustomerCash customerCash = customerCashService.findByUserUuid(userUuid);
        return R.ok(customerCash);
    }

    @PostMapping("/cash/add-amt")
    public R cashAdd(@RequestBody CustomerCashCrudReq req) {
        customerCashService.addAmt(req);
        return R.ok();
    }
}
